﻿using System;
using System.Xml;

namespace YArchitech.HCLoad.Export
{
	public class HcXmlElement
	{
		public HcXmlElement()
		{
		}

		public HcXmlElement(HcDataManager dataManager)
		{
			this.m_dataManager = dataManager;
		}

		public HcDataManager DataManager
		{
			get
			{
				return this.m_dataManager;
			}
		}

		public virtual bool WriteElementData(ref XmlElement xmlElement)
		{
			return true;
		}

		public static XmlElement AppendTextElement(ref XmlElement elemParent, string sElementName, string sValue)
		{
			XmlDocument ownerDocument = elemParent.OwnerDocument;
			XmlElement xmlElement = ownerDocument.CreateElement(sElementName);
			xmlElement.AppendChild(ownerDocument.CreateTextNode(sValue));
			elemParent.AppendChild(xmlElement);
			return xmlElement;
		}

		public static XmlElement AppendTextElement(ref XmlElement elemParent, string sElementName, double dValue)
		{
			XmlDocument ownerDocument = elemParent.OwnerDocument;
			XmlElement xmlElement = ownerDocument.CreateElement(sElementName);
			xmlElement.AppendChild(ownerDocument.CreateTextNode(dValue.ToString()));
			elemParent.AppendChild(xmlElement);
			return xmlElement;
		}

		private HcDataManager m_dataManager;
	}
}
